<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/6/27
 * Time: 上午10:24
 */

namespace app\mall\controller;


use think\Request;

class Collection extends Auth
{
    /**
     * @purpose 获取收藏的商品列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function goodsItem ()
    {
        return \app\mall\logic\Collection::goodsItem(self::$uid);
    }
    /**
     * @purpose 收藏商品
     * @param Request $request
     * @return array
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function goods (Request $request)
    {
        $goods_id      =   $request->post('goods_id');
        return \app\mall\logic\Collection::goods($goods_id, self::$uid);
    }

    /**
     * @purpose 取消收藏
     * @param Request $request
     * @return array
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function unGoods (Request $request)
    {
        $goods_ids     = $request->post();
        return \app\mall\logic\Collection::unGoods($goods_ids, self::$uid);
    }
}